package com.erp.module.YuliaoPrint.DayinYuliaoActivity

import android.content.Context
import com.erp.Interface.OnUserDataInterface
import com.erp.module.YuliaoPrint.YuliaoPrintContract
import com.erp.module.YuliaoPrint.YuliaoPrintModel
import com.erp.util.JsonUtil
import com.erp.util.Myutil
import org.json.JSONObject
import java.util.ArrayList

class DayinYuliaoP(var context: Context,var V : YuliaoPrintContract.DayingYuliaoView):YuliaoPrintContract.DayingYuliaoP {

    var md = YuliaoPrintModel()
    override fun postBiaoshi(mid: String,position: String,kailiao_time:String,kailiao_wu_id:String) {
        md.postIdentifying_yuliao(context,mid,position,kailiao_time,kailiao_wu_id,object : OnUserDataInterface {
            override fun onUserData(data: String?) {
                val jo = JSONObject(data)
                V.postBiaoshiOk(JsonUtil.getvolue(jo,"msg"))
            }

            override fun onNot(throwable: String?) {
                V.postBiaoshiNo()
            }

        })
    }

    override fun getwage_user() {
        var names: MutableList<String> = ArrayList()
        var uids: MutableList<String> = ArrayList()
        md.getWage_user(context,object : OnUserDataInterface{
            override fun onUserData(data: String?) {
                val jo = JSONObject(data)
                val keys = jo.keys()
                while (keys.hasNext()) {
                    val key = keys.next()
                    uids.add(key)
                    names.add(JsonUtil.getvolue(jo, key))
                }
                V.getwage_userOk(uids,names)
            }

            override fun onNot(throwable: String?) {
                V.getwage_userNo()
            }

        })
    }

}